POV-Ray : Newsgroups : povray.newusers : Random Number Generation : Re: Random Number Generation Server Time
5 Sep 2024 10:28:27 EDT (-0400)
  Re: Random Number Generation  
From: Josh English
Date: 26 Feb 2001 11:50:35
Message: <3A9A89B3.F7059895@spiritone.com>
The simplest way to do this is:
#declare lower_bound = something;
#declare upper_bound = somethingelse;

#declare MySeed = seed(2531); // or some other number, big and prime is nice

object { whatever
              translate lower_bound + rand(MySeed)*(upper_bound - lower_bound) }

// end
something and something else can be vectors, but they will distribute within a
straight line, so you will have to do this in triplicate for three different
vectors to fill space.


Reuben Pearse wrote:

> Hi all,
>
> I have created a macro to create an object. I now want to randomly place the
> object in my scene (within specified boundaries!!)
> How do I get POVRay to generate random numbers?
>
> Thanks,
>
> Reuben

--
Josh English -- Lexiphanic Lethomaniac
eng### [at] spiritonecom
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/
"He who hebetates is last."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.